package cn.dhnep.demo.service.impl;

import cn.dhnep.demo.mapper.tb_Order_ItemMapper;
import cn.dhnep.demo.service.TbOrderItemService;

import cn.dhnep.demo.util.Time;
import cn.dhnep.demo.util.dataSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class TbOrderItemServiceImpl implements TbOrderItemService {


    @Autowired
    tb_Order_ItemMapper tb_order_itemMapper ;

    @Override
    public dataSummary queryReceivingToTime(String InitialTime, String EndTime) {
        Time time = new Time();
        time.setInitialTime(InitialTime);
        time.setEndTime(EndTime);
        dataSummary dataSummary = new dataSummary();
        Double Total = tb_order_itemMapper.selectTotalByTimeReceiving(time);
        Double WasteClothes = tb_order_itemMapper.selectWasteClothesByTimeReceiving(time);
        Double MetalScrap = tb_order_itemMapper.selectMetalScrapByTimeReceiving(time);
        Double OtherWastes = tb_order_itemMapper.selectOtherWastesByTimeReceiving(time);
        Double WasteGlass = tb_order_itemMapper.selectWasteGlassByTimeReceiving(time);
        Double WastePaper = tb_order_itemMapper.selectWastePaperByTimeReceiving(time);
        Double WastePlastics = tb_order_itemMapper.selectWastePlasticsByTimeReceiving(time);
        Integer WasteHouseholdAppliances = tb_order_itemMapper.selectWasteHouseholdAppliancesByTimeReceiving(time);


        if(Total == null ){
            double TotalDouble = 0;
            Total = TotalDouble;
            System.out.println(Total + " 总计数据为0");
        }
        if(WasteClothes == null ){
            double WasteClothesDouble = 0;
            WasteClothes = WasteClothesDouble;
            System.out.println(WasteClothes + " 废旧衣服数据为0");
        }
        if(MetalScrap == null ){
            double MetalScrapDouble = 0;
            MetalScrap = MetalScrapDouble;
            System.out.println(MetalScrap + " 废金属数据为0");
        }
        if(WasteGlass == null ){
            double WasteGlassDouble = 0;
            WasteGlass = WasteGlassDouble;
            System.out.println(WasteGlass + " 废玻璃数据为0");
        }
        if(WastePaper == null ){
            double WastePaperDouble = 0;
            WastePaper = WastePaperDouble;
            System.out.println(WastePaper + " 废纸张数据为0");
        }
        if(WasteHouseholdAppliances == null ){
            Integer WasteHouseholdAppliancesInteger = 0;
            WasteHouseholdAppliances = WasteHouseholdAppliancesInteger;
            System.out.println(WasteHouseholdAppliances + " 废旧家电数据为0");
        }

        if(OtherWastes == null){
            double WastePaperDouble = 0;
            WastePaper = WastePaperDouble;
            System.out.println(WastePaper + " 其他废品数据为0");
        }

        if (WastePlastics == null){
            double WastePaperDouble = 0;
            WastePaper = WastePaperDouble;
            System.out.println(WastePaper + " 废塑料数据为0");
        }

        dataSummary.setTotal(Total);
        dataSummary.setMetalScrap(MetalScrap);
        dataSummary.setOtherWastes(OtherWastes);
        dataSummary.setWasteClothes(WasteClothes);
        dataSummary.setWasteGlass(WasteGlass);
        dataSummary.setWastePaper(WastePaper);
        dataSummary.setWastePlastics(WastePlastics);
        dataSummary.setWasteHouseholdAppliances(WasteHouseholdAppliances);
        dataSummary.setTime(new Time(InitialTime,EndTime));
        return dataSummary;
    }

    @Override
    public dataSummary queryRecoveryToTime(String InitialTime, String EndTime) {
        Time time = new Time();
        time.setInitialTime(InitialTime);
        time.setEndTime(EndTime);
        dataSummary dataSummary = new dataSummary();
        Double Total = tb_order_itemMapper.selectTotalByTimeRecovery(time);
        Double WasteClothes = tb_order_itemMapper.selectWasteClothesByTimeRecovery(time);
        Double MetalScrap = tb_order_itemMapper.selectMetalScrapByTimeRecovery(time);
        Double OtherWastes = tb_order_itemMapper.selectOtherWastesByTimeRecovery(time);
        Double WasteGlass = tb_order_itemMapper.selectWasteGlassByTimeRecovery(time);
        Double WastePaper = tb_order_itemMapper.selectWastePaperByTimeRecovery(time);
        Double WastePlastics = tb_order_itemMapper.selectWastePlasticsByTimeRecovery(time);
        Integer WasteHouseholdAppliances = tb_order_itemMapper.selectWasteHouseholdAppliancesByTimeRecovery(time);


        if(Total == null ){
            double TotalDouble = 0;
            Total = TotalDouble;
            System.out.println(Total + " 总计数据为0");
        }
        if(WasteClothes == null ){
            double WasteClothesDouble = 0;
            WasteClothes = WasteClothesDouble;
            System.out.println(WasteClothes + " 废旧衣服数据为0");
        }
        if(MetalScrap == null ){
            double MetalScrapDouble = 0;
            MetalScrap = MetalScrapDouble;
            System.out.println(MetalScrap + " 废金属数据为0");
        }
        if(WasteGlass == null ){
            double WasteGlassDouble = 0;
            WasteGlass = WasteGlassDouble;
            System.out.println(WasteGlass + " 废玻璃数据为0");
        }
        if(WastePaper == null ){
            double WastePaperDouble = 0;
            WastePaper = WastePaperDouble;
            System.out.println(WastePaper + " 废纸张数据为0");
        }
        if(WasteHouseholdAppliances == null ){
            Integer WasteHouseholdAppliancesInteger = 0;
            WasteHouseholdAppliances = WasteHouseholdAppliancesInteger;
            System.out.println(WasteHouseholdAppliances + " 废旧家电数据为0");
        }

        if(OtherWastes == null){
            double WastePaperDouble = 0;
            OtherWastes = WastePaperDouble;
            System.out.println(OtherWastes + " 其他废品数据为0");
        }

        if (WastePlastics == null){
            double WastePaperDouble = 0;
            WastePaper = WastePaperDouble;
            System.out.println(WastePaper + " 废塑料数据为0");
        }

        dataSummary.setTotal(Total);
        dataSummary.setMetalScrap(MetalScrap);
        dataSummary.setOtherWastes(OtherWastes);
        dataSummary.setWasteClothes(WasteClothes);
        dataSummary.setWasteGlass(WasteGlass);
        dataSummary.setWastePaper(WastePaper);
        dataSummary.setWastePlastics(WastePlastics);
        dataSummary.setWasteHouseholdAppliances(WasteHouseholdAppliances);
        dataSummary.setTime(new Time(InitialTime,EndTime));
        return dataSummary;
    }
}
